#include <vector>

using namespace std;

class Solution
{
public:
    int numSpecial(vector<vector<int>> &mat)
    {
        int cout = 0;
        for (int i = 0; i < mat.size();++i)
        {
            for (int j = 0; j < mat[i].size();++j)
            {
                if (mat[i][j] == 1)
                {
                    int t = 0;
                    for (int tmp = 0; tmp < mat[i].size();++tmp)
                    {
                        if (mat[i][tmp] == 1) 
                        {
                            ++t;
                        }
                    }

                    for (int tmp = 0; tmp < mat.size();++tmp)
                    {
                        if (mat[tmp][j] == 1)
                        {
                            ++t;
                        }
                    }

                    if (t == 2)
                    {
                        ++cout;
                    }
                }
            }
            return cout;
        }
    }
};